//
//  PBViewController.mm
//  PlatinumButler
//
//  Created by 高小松 on 14-3-10.
//  Copyright (c) 2014年 gxsoft. All rights reserved.
//

#import "PBViewController.h"
#import "PBTabBarViewController.h"
#import "PBHomePageViewController.h"
#import "PBLifePageViewController.h"
#import "PBManagePageViewController.h"
#import "PBMorePageViewController.h"

@implementation PBViewController

#pragma mark - 内存管理

- (id)init
{
    self = [super init];
    if (self) {
        _tabBarController = [[PBTabBarViewController alloc] init];
        _homePageController = [[PBHomePageViewController alloc] init];
        _lifePageController = [[PBLifePageViewController alloc] init];
        _managePageController = [[PBManagePageViewController alloc] init];
        _morePageController = [[PBMorePageViewController alloc] init];
    }
    return self;
}

- (void)dealloc
{
    [_bgNaviController release];
    [_tabBarController release];
    [_homePageController release];
    [_lifePageController release];
    [_managePageController release];
    [_morePageController release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - 视图管理

- (void)loadView
{
    CGRect rect = [[UIScreen mainScreen] bounds];
    // 本身视图
    UIView * v = [[[UIView alloc] initWithFrame:rect] autorelease];
    v.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    v.backgroundColor = [UIColor whiteColor];
    self.view = v;
    // 导航
    _bgNaviController = [[UINavigationController alloc] initWithRootViewController:_tabBarController];
    _bgNaviController.view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
    _bgNaviController.navigationBarHidden = YES;
    [self.view addSubview:_bgNaviController.view];
    // 标签页
    _tabBarController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    _tabBarController.view.backgroundColor = [UIColor clearColor];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    _tabBarController.viewControllers = [NSArray arrayWithObjects:_homePageController, _lifePageController, _managePageController, _morePageController, nil];
}

@end
